#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
//多数元素
int majorityElement(int* nums, int numsSize)
{
    int count = 0;
    int i = 0;
    for (i = 0; i < numsSize; i++)
    {
        int  j = 0;
        count = 0;
        for (j = 0; j < numsSize; j++)
        {
            if (*(nums + i) == *(nums + j))
            {
                count++;
            }
        }
        if (count > numsSize / 2)
        {
            goto end;
        }

    }
end:return *(nums + i);
}
int main()
{
    int nums[] = { 2,2,1,1,1,2,2 };
    int numsSize = sizeof(nums) / sizeof(nums[0]);
    int ret = majorityElement(nums, numsSize);
    printf("%d", ret);
    return 0;
}